package com.deyou.fragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.deyou.R;
import com.deyou.util.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class CalenderPopUpFragment extends DialogFragment {

    @BindView(R.id.edt_price)
    EditText edtPrice;
    @BindView(R.id.cb_rent)
    CheckBox cbRent;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.fragment_calender_pop_up, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    public static CalenderPopUpFragment newInstance(String date) {
        CalenderPopUpFragment fragment = new CalenderPopUpFragment();
        Bundle bundle = new Bundle();
        bundle.putString("select_date", date);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.btn_cancel, R.id.btn_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_cancel:
                dismiss();
                break;
            case R.id.btn_confirm:
                dismiss();
                Logger.i(Logger.LOGTAG + "日历价格", cbRent.isChecked() ? "时间段: " + getArguments().getString("select_date") + "内\n" + "设置的价格为: " + edtPrice.getText().toString() : "设置为不准出租了");
                break;
        }
    }
}
